<div id="view-content">
<?php include_once '/../supMenu.html';?>
	<br>
	<h2 class="backend-h2"><span class="img"></span><span> Xem điểm</span>
    </h2>

    <p class="saporator"><br /></p>
    
    <div>
		<form action="<?php echo $this->baseUrl('/admin/mark/');?>" method="post" >
			<div class="table_nav_left">
               	<select id="tbn_cat" name="tbn_cate">
                    <option value="0" selected="selected">Hiển thị tất cả</option>
                <?php 
                	foreach ($this->khoaHocs as $khoaHoc) {
					if(isset($_REQUEST['khoa']) && $_REQUEST['khoa'] == $khoaHoc['khoa']){
						echo '<option value="'.$khoaHoc['khoa'].'" selected>Khóa '.$khoaHoc['khoa'].'</option>';
					}else{
						echo '<option value="'.$khoaHoc['khoa'].'">Khóa '.$khoaHoc['khoa'].'</option>';	
					}
				}
                ?>                 
                </select>
                    
                <input type="submit" value="Lọc" name="tbn_filter" class="tbn_button input-hover"/> <!-- tbn: là viết tắt của từ table_nav trong div class="table_nav" -->
            	<input type="submit" value="Xóa" name="del" class="tbn_button input-hover"/>
            </div><!-- end .table_nav_left -->
            
            <p class="search_box">
	            <input class="sbt hover focus" type="text" name="search_box_text" title="Nhập vào tên cần tìm"/>
	            <input class="sbc input-hover" type="submit" name="search_box_sumit"  value="Tìm" style="min-height: 38px; "/>
	        </p><!-- End .search_box-->
	        
            <table>
            	<tr>
            		<td class="col-1-mark-view">Chọn lớp cầm xem</td>
            		<td>
            			<select name="cbbLop" class="lop-list-select" id="mark-cbb-lop">
							<?php foreach ($this->lops as $lop) {
								echo '<option value="'.$lop['id'].'">'.$lop['tenLop'].'</option>';
							}?>
						</select>
            		</td>
            	</tr>
            	<tr>
            		<td class="col-1-mark-view">Chọn môn học</td>
            		<td>
            			<select name ="cbbMon" id="mark-cbb-mon">
					<option value="0">Chọn môn để xem điểm</option>
						<?php 
							foreach ($this->mons as $mon) {
								if(isset($_REQUEST['cbbMon']) && $_REQUEST['cbbMon']== $mon['id']){
									echo '<option value="'.$mon['id'].'" selected>'.$mon['tenMonHoc'].'</option>';	
								}else{
									echo '<option value="'.$mon['id'].'">'.$mon['tenMonHoc'].'</option>';
								}
								
							}
						?>
					</select>
            		</td>
            	</tr>
            	
            </table>
              
           <input type="submit" name="cmdView" value="Xem">
		</form>    
    </div>
    
	<div class="mon-mark">
		<form action="<?php echo $this->baseUrl('/admin/mark/'); ?>" method="get">
			<div class="table_nav_pages">  
                <?php 
                	//phan trang
					echo $this->paginationControl($this->paginatorMark,'sliding','tinyPaginator.phtml');
				?>                           
			</div>
	        <table id="p_post">
	            <thead>
	                <tr>
	                    <th class="col-1-mark"><input class="check-all" type="checkbox" /></th>
	                    <th class="col-2-mark">Họ và tên</th>
	                    <th class="col-3-mark">Hệ số 1</th>
	                    <th class="col-4-mark">Hệ số 2</th>
	                    <th class="col-5-mark">Điểm thi</th>
	                    <th class="col-6-mark">Học kỳ</th>
	                    <th class="col-7-mark">Năm học</th>
	                </tr>
	            </thead>
	            <tbody>
	            <?php 
	            	foreach ($this->paginatorMark as $mark) {
	            ?>    
	                <tr>
	                    <th class="col-1-mark">
	                        <input class="sub-check" name="lop-check[]" type="checkbox" value="<?php echo $mark['username'];?>"/>
	                    </th>
	                    <th class="col-2-mark post_title">
	                    	<strong><a href="" class="title_ct"><?php echo $mark['hoDem']." ".$mark['ten'];?></a></strong> 
		                    <div class="row_action">
		                        <span class="row_edit">
		                        	<a href="<?php echo $this->baseUrl('/admin/mark/inputmark/?edit&lop='.$mark['idLop'].'&user='.$mark['username'].'&mon='.$mark['idMonHoc']);?>">Sửa</a>|
		                        </span>
		                        <span class="row_del">
		                        	<a href="<?php echo $this->baseUrl('/admin/mark/delete/?lop='.$mark['idLop'].'&user='.$mark['username'].'&mon='.$mark['idMonHoc']);?>">Xóa</a>
		                        </span>                        
		                    </div>
	                    </th>
	                    <th class="col-3-mark "><?php echo $mark['diemHeSo1'];?> </th>
	                    
	                    <th class="col-4-mark"><?php echo $mark['diemHeSo2']; ?></th>
	                    <th class="col-5-mark"><?php echo $mark['diemThi']; ?></th>
	                    <th class="col-6-mark"><?php echo $mark['hocKy'];?></th>
	                    <th class="col-7-mark"><?php echo $mark['namHoc'];?></th>
	                </tr>                                          
	            <?php 
	            	}
	            ?>             
	            </tbody>
	            <tfoot>
	                <tr>
	                    <th class="col-1-mark"><input class="check-all" type="checkbox" /></th>
	                    <th class="col-2-mark">Họ và tên</th>
	                    <th class="col-3-mark">Hệ số 1</th>
	                    <th class="col-4-mark">Hệ số 2</th>
	                    <th class="col-5-mark">Điểm thi</th>    
	                    <th class="col-6-mark">Học kỳ</th>
	                    <th class="col-7-mark">Năm học</th>      
	                </tr>
	            </tfoot>
	        </table>
 
	 </form>
	</div>
</div>

<script type="text/javascript" >
(function( $ ) {
	$.widget( "ui.combobox", {
		_create: function() {
			var self = this,
				select = this.element.hide(),
				selected = select.children( ":selected" ),
				value = selected.val() ? selected.text() : "";
			var input = this.input = $( "<input>" )
				.insertAfter( select )
				.val( value )
				.autocomplete({
					delay: 0,
					minLength: 0,
					source: function( request, response ) {
						var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
						response( select.children( "option" ).map(function() {
							var text = $( this ).text();
							if ( this.value && ( !request.term || matcher.test(text) ) )
								return {
									label: text.replace(
										new RegExp(
											"(?![^&;]+;)(?!<[^<>]*)(" +
											$.ui.autocomplete.escapeRegex(request.term) +
											")(?![^<>]*>)(?![^&;]+;)", "gi"
										), "<strong>$1</strong>" ),
									value: text,
									option: this
								};
						}) );
					},
					select: function( event, ui ) {
						ui.item.option.selected = true;
						self._trigger( "selected", event, {
							item: ui.item.option
						});
					},
					change: function( event, ui ) {
						if ( !ui.item ) {
							var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
								valid = false;
							select.children( "option" ).each(function() {
								if ( $( this ).text().match( matcher ) ) {
									this.selected = valid = true;
									return false;
								}
							});
							if ( !valid ) {
								// remove invalid value, as it didn't match anything
								$( this ).val( "" );
								select.val( "" );
								input.data( "autocomplete" ).term = "";
								return false;
							}
						}
					}
				})
				.addClass( "ui-widget ui-widget-content ui-corner-left" );

			input.data( "autocomplete" )._renderItem = function( ul, item ) {
				return $( "<li></li>" )
					.data( "item.autocomplete", item )
					.append( "<a>" + item.label + "</a>" )
					.appendTo( ul );
			};

			this.button = $( "<button type='button'>&nbsp;</button>" )
				.attr( "tabIndex", -1 )
				.attr( "title", "Show All Items" )
				.insertAfter( input )
				.button({
					icons: {
						primary: "ui-icon-triangle-1-s"
					},
					text: false
				})
				.removeClass( "ui-corner-all" )
				.addClass( "ui-corner-right ui-button-icon" )
				.click(function() {
					// close if already visible
					if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
						input.autocomplete( "close" );
						return;
					}

					// work around a bug (likely same cause as #5265)
					$( this ).blur();

					// pass empty string as value to search for, displaying all results
					input.autocomplete( "search", "" );
					input.focus();
				});
		},

		destroy: function() {
			this.input.remove();
			this.button.remove();
			this.element.show();
			$.Widget.prototype.destroy.call( this );
		}
	});
})( jQuery );

$(function(){
	$( "#tbn_cat, #mark-cbb-mon, #mark-cbb-lop" ).combobox();	
});
</script>
